package com.xg.te.core.bean;

import java.util.List;

/**
 * 代理商配置
 * 
 * @author liuguojun
 */
public class WebsiteBean {

	private List<ConstantBean> constants; // 模块页面
	private List<PageReference> pages; // 模块页面

	public List<ConstantBean> getConstants() {
		return constants;
	}

	public void setConstants(List<ConstantBean> constants) {
		this.constants = constants;
	}

	public List<PageReference> getPages() {
		return pages;
	}

	public void setPages(List<PageReference> pages) {
		this.pages = pages;
	}

	public String getConstantValue(String name) throws Exception {
		String value = null;

		if (constants == null) {
			throw new Exception("constants of agent is null!");
		}

		if (name == null) {
			throw new Exception("name is null!");
		}

		for (ConstantBean constant : constants) {
			String tname = constant.getName();
			String tvalue = constant.getValue();
			if (name.equals(tname)) {
				value = tvalue;
				break;
			}
		}
		
		if (value == null) {
			throw new Exception("name is not found!");
		}

		return value;
	}
}
